#include "common.h"
#include "gvariable.h"

CGVariable::CGVariable(void)
{
	m_nID = -1;
	m_pObject = NULL;
}

CGVariable::~CGVariable(void)
{
}

bool CGVariable::Create(CGShader* pShader, const std::string& szName)
{
	m_pObject = glCreateProgramObjectARB();
	pShader->AttachObject(m_pObject);
	glLinkProgramARB(m_pObject);
	glUseProgramObjectARB(m_pObject);
	m_nID = glGetUniformLocationARB(m_pObject, szName.c_str());
	return true;
}

void CGVariable::UniformInt(int nValue)
{
	glUniform1iARB(m_nID, nValue);
}

void CGVariable::UniformFloat(float fValue)
{
	glUniform1fARB(m_nID, fValue);
}

void CGVariable::UniformMatrix4(float * pMatrix)
{
	glUniformMatrix4fvARB(m_nID, 1, GL_TRUE, pMatrix);
}
